/*     */ package com.zimbra.cs.dav;
/*     */ 
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import java.io.IOException;
/*     */ import java.io.OutputStream;
/*     */ import org.dom4j.Document;
/*     */ import org.dom4j.DocumentHelper;
/*     */ import org.dom4j.Element;
/*     */ import org.dom4j.QName;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DavException
/*     */   extends Exception
/*     */ {
/*     */   protected boolean mStatusIsSet;
/*     */   protected int mStatus;
/*     */   protected Document mErrMsg;
/*     */   
/*     */   public DavException(String msg, int status)
/*     */   {
/*  38 */     super(msg);
/*  39 */     this.mStatus = status;
/*  40 */     this.mStatusIsSet = true;
/*     */   }
/*     */   
/*     */   public DavException(String msg, Throwable cause) {
/*  44 */     super(msg, cause);
/*  45 */     this.mStatusIsSet = false;
/*     */   }
/*     */   
/*     */   public DavException(String msg, int status, Throwable cause) {
/*  49 */     super(msg, cause);
/*  50 */     this.mStatus = status;
/*  51 */     this.mStatusIsSet = true;
/*     */   }
/*     */   
/*     */   public boolean isStatusSet() {
/*  55 */     return this.mStatusIsSet;
/*     */   }
/*     */   
/*     */   public int getStatus() {
/*  59 */     return this.mStatus;
/*     */   }
/*     */   
/*     */   public boolean hasErrorMessage() {
/*  63 */     return this.mErrMsg != null;
/*     */   }
/*     */   
/*     */   public Element getErrorMessage() {
/*  67 */     if (this.mErrMsg == null)
/*  68 */       return null;
/*  69 */     return this.mErrMsg.getRootElement();
/*     */   }
/*     */   
/*     */   public void writeErrorMsg(OutputStream out) throws IOException {
/*  73 */     if (ZimbraLog.dav.isDebugEnabled()) {
/*  74 */       ZimbraLog.dav.debug("ERROR RESPONSE\n%s", new Object[] { this.mErrMsg.asXML() });
/*     */     }
/*  76 */     DomUtil.writeDocumentToStream(this.mErrMsg, out);
/*     */   }
/*     */   
/*     */   protected static class DavExceptionWithErrorMessage extends DavException {
/*     */     protected DavExceptionWithErrorMessage(String msg, int status) {
/*  81 */       super(status);
/*  82 */       this.mErrMsg = DocumentHelper.createDocument();
/*  83 */       this.mErrMsg.addElement(DavElements.E_ERROR);
/*     */     }
/*     */     
/*  86 */     protected void setError(QName error) { this.mErrMsg.getRootElement().addElement(error); }
/*     */     
/*     */ 
/*  89 */     protected void setError(Element error) { this.mErrMsg.getRootElement().add(error); }
/*     */   }
/*     */   
/*     */   public static class CannotModifyProtectedProperty extends DavException.DavExceptionWithErrorMessage {
/*     */     public CannotModifyProtectedProperty(QName prop) {
/*  94 */       super(403);
/*  95 */       setError(DavElements.E_CANNOT_MODIFY_PROTECTED_PROPERTY);
/*     */     }
/*     */   }
/*     */   
/*     */   public static class PropFindInfiniteDepthForbidden extends DavException.DavExceptionWithErrorMessage {
/* 100 */     public PropFindInfiniteDepthForbidden() { super(403);
/* 101 */       setError(DavElements.E_PROPFIND_FINITE_DEPTH);
/*     */     }
/*     */   }
/*     */   
/*     */   public static class UnsupportedReport extends DavException.DavExceptionWithErrorMessage {
/*     */     public UnsupportedReport(QName report) {
/* 107 */       super(403);
/* 108 */       Element e = DocumentHelper.createElement(DavElements.E_SUPPORTED_REPORT);
/* 109 */       e.addElement(DavElements.E_REPORT).addElement(report);
/* 110 */       setError(e);
/*     */     }
/*     */   }
/*     */   
/*     */   public static class InvalidData extends DavException.DavExceptionWithErrorMessage {
/*     */     public InvalidData(QName prop, String msg) {
/* 116 */       super(403);
/* 117 */       setError(prop);
/*     */     }
/*     */   }
/*     */   
/*     */   public static class NeedSameOrganizerInAllComponents
/*     */     extends DavException.DavExceptionWithErrorMessage
/*     */   {
/*     */     public NeedSameOrganizerInAllComponents(String msg)
/*     */     {
/* 126 */       super(403);
/* 127 */       Element e = DocumentHelper.createElement(DavElements.E_SAME_ORGANIZER_IN_ALL_COMPONENTS);
/* 128 */       setError(e);
/*     */     }
/*     */   }
/*     */   
/*     */   public static class REPORTwithDisallowedDepthException extends DavException {
/*     */     public REPORTwithDisallowedDepthException(String reportName, DavContext.Depth depth) {
/* 134 */       super(400);
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/dav/DavException.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */